#include "DecoratorBuilder.h"

#include "ScriptCompiler/Token/Token.h"
#include "ScriptCompiler/AST/DecoratorNode.h"
#include "ScriptCompiler/ScriptFileContext.h"

bool IsDecorator(EScriptTokenType Type)
{
    switch(Type)
    {
        case EScriptTokenType::Abstract:
        case EScriptTokenType::Static:
        case EScriptTokenType::Virtual:
        case EScriptTokenType::Override:
        case EScriptTokenType::Const:
            return true;

        default:
            return false;
    }
}


CDecoratorBuilder::CDecoratorBuilder(std::shared_ptr<CScriptFileContext> InContext)
{
    Context = InContext;
    Result = std::make_shared<CDecoratorNode>(Context);
}

bool CDecoratorBuilder::ReadCurentToken()
{
    while(IsDecorator(Context->GetCurrentToken()->Type))
    {
        Result->Decorators.Add(Context->GetCurrentToken());
        Context->CurrentTokenIndex++;
    }

    return true;
}
